package com.mvu.banana.tools;

/**
 * Class description...
 *
 * @author gantz
 */
public class ToStringMethod extends JavaMethod{
  public ToStringMethod(JavaClass parent) {
    super(parent);
    withName("toString").withReturnType(String.class);
    addLine("StringBuilder builder = new StringBuilder()");
    for (JavaField field : this.javaClass.fields) {
      if(!field.type.isCollection){
        addLine("builder.append(\"", field.name, "=\")",
              ".append(this.", field.name, ").append(\", \")");
      }
    }
    addLine("return builder.toString()");
  }
}
